<template>
	<view>
		<view class="title">
			<text>编号:{{pig_data.id}}</text>
			<text>品种:{{pig_data.type}}</text>
		</view>
		<view class="line">
			<line-chart :dataAs="pig_data.temperatures"  canvasId="index1"/>
			<view style="text-align: center;line-height: 40px;">体温监测</view>
		</view>
		<view class="line">
			<line-chart :dataAs="pig_data.fats"  canvasId="index2" 	:basicAs="{colors: ['#ff7600']}" :yAxisAs="{
					formatter: {
						type: 'percent', //type:number percent String,额外参数:fixed:NUmber,name:String
						fixed: 2
					}
				}"/>
			<view style="text-align: center;line-height: 40px;">体脂监测</view>
		</view>		
	</view>
</template>

<script>
	import LineChart from '@/components/stan-ucharts/LineChart.vue';
	export default {
		components: {
			LineChart,
		},
		onLoad(options){
			let id=options.id;
			this.getData(id);
		},
		data() {
			return {
				pig_data:'',
				temperatures: {
					//数字的图--折线图数据
					categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
					series: [
						{ name: '体温', data: [36, 37, 36.5, 36.8, 36.4,  36.7] }
					]
				},				
				fats: {
					//数字的图--折线图数据
					categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
					series: [
						{ name: '体脂', data: [0.7, 0.4, 0.65, 0.3, 0.44, 0.68] },
					]
				},
				
			}
		},
		methods: {
			getData(id){
				let list=[
					{
						"id":"0021",
						"type":"绿毛猪",
						"temperature":"36",
						"fat":"36",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.1, 36.2, 36.4, 36.9, 36.6,  36.5] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.11, 0.2, 0.4, 0.3, 0.6, 0.7] },
							]
						},
					},
					{	
						"id":"0045",
						"type":"紫毛猪",
						"temperature":"37",
						"fat":"46",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.5, 36.2, 36.3, 36.9, 36.7,  36.2] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.31, 0.52, 0.64, 0.23, 0.46, 0.97] },
							]
						},
					},
					{
						"id":"0225",
						"type":"蓝毛猪",
						"temperature":"36",
						"fat":"36",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.5, 36.6, 36.7, 36.1, 36.9,  36.3] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.21, 0.12, 0.41, 0.33, 0.56, 0.17] },
							]
						},
					},
					{	
						"id":"0115",
						"type":"黄毛猪",
						"temperature":"37",
						"fat":"46",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.7, 36.6, 36.2, 36.3, 36.1,  36.7] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.41, 0.22, 0.44, 0.53, 0.26, 0.77] },
							]
						},
					},
					{	
						"id":"0025",
						"type":"黑毛猪",
						"temperature":"36",
						"fat":"36",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.1, 36.8, 36.4, 36.5, 36.9,  36.7] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.41, 0.18, 0.36, 0.46, 0.54, 0.72] },
							]
						},
					},
					{	
						"id":"0015",
						"type":"白毛猪",
						"temperature":"37",
						"fat":"46",
						temperatures: {
							//数字的图--折线图数据
							categories: ['11:00', '12:00', '13:00', '14:00', '15:00', '16:00'],
							series: [
								{ name: '体温', data: [36.4, 36.3, 36.5, 36.6, 36.2,  36.9] }
							]
						},				
						fats: {
							//数字的图--折线图数据
							categories: ['7月1日', '7月2日', '7月3日', '7月4日', '7月5日', '7月6日'],
							series: [
								{ name: '体脂', data: [0.71, 0.8, 0.16, 0.36, 0.44, 0.2] },
							]
						},
					}
				];
				for (var i = 0; i < list.length; i++) {
					if(list[i].id==id){
						this.pig_data=list[i];
						break;
					}
				}
			}
		}
	}
</script>

<style scoped>
	.title{
		margin-top: 5%;
		padding: 4%;
	}
	.title text:nth-child(2){
		float: right;
	}
</style>
